<div class="clearfix row-main" ng-controller="apidoc/docEditorCtrl">

	<div class='panel'>
		<div class="panel-heading clearfix" style="padding-bottom: 4px;padding-left:4px;" >
			<div class="panel-actions" style="float: left;margin-right:20px;margin-left:0;">
				<a href='javascript:void(0)'  class='btn btn-primary pull-left' style='margin-left:0;' ui-sref="project.doc({id:project_id})"><i class='icon icon-double-angle-left'></i>返回上级</a>
			</div>
			<ul id='typeNav' class='nav nav-tabs pull-left'>
				<li data-type='internal' class="active"><a href="javascript:void(0)" > 编辑版本</a></li>
			</ul>
		</div>

		<form class="form-horizontal" role="form" id="form"
			style="margin-top: 20px">
			<input type="text" name='doc.id' ng-model='doc_id' ng-show='false' />
			<input type="text" name='docVer.id' ng-model='id' ng-show='false' />
			
			<div class="form-group">
				<label class="col-md-1 control-label required" >文档名称</label>
				<div class="col-md-2">
					<input type='text' ng-model='doc.name' name='doc.name' class='form-control' />
				</div>
				
				<label class="col-md-1 control-label no-padding-right" for="state">类型</label>
				<div class="col-md-2">
					<div class="radio">
						<label><input type="radio" class="state" name="doc.state" value="1">接口</label>
						&emsp;
						<label><input type="radio" class="state" name="doc.state" value="2">文档</label>
					</div>
				</div>
			</div>

			<div class="form-group">
				<label class="col-md-1 control-label"> 排序序号</label>
				<div class="col-md-2">
					<input type="text" ng-model='doc.seq' name='doc.seq' placeholder="排序序号" class="form-control" />
				</div>
				
				<label class="col-md-1 control-label required" for="url">版本号</label>
				<div class="col-md-2">
					<select class="form-control" ng-change="verSelect()" ng-model="verItem" ng-options="x.id as x.version for x in verList"></select>
				</div>
			</div>

			<div class="form-group">
				<div class="col-md-1">
				</div>
				<div class="col-md-5">
					<button type="button" class="btn" data-position="100px" ng-click="openTemplate()" data-toggle="modal" data-target="#templateModal">选择模板</button>
				</div>
			</div>

			<div class="form-group">
				<!--editormd编辑器  -->
				<div class="col-md-12">
					<div id="doc-editormd">
						<textarea style="display: none;"></textarea>
					</div>
				</div>
			</div>

			<div class="form-group">
				<div class="col-md-offset-1 col-md-10">
					<input type="submit" class='btn btn-primary' value='保存' data-loading='稍候...' ng-click="saveBtn()" /> 
					<input type="button" class='btn btn-primary' value='另存为模板' data-loading='稍候...' ng-click="saveTemplateBtn()" />
					<a href='javascript:void(0)' class='btn' ui-sref="project.doc({id:project_id})">返回</a>
				</div>
			</div>
			
		</form>
	</div>
</div>

<!-- 模板对话框 -->
<div class="modal fade" id="templateModal">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">×</span><span class="sr-only">关闭</span></button>
        <h4 class="modal-title">模板列表</h4>
      </div>
      <div class="modal-body">
      		
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
      </div>
    </div>
  </div>
</div>


<script type="text/javascript">
	var docEditor;
	var content_code="";
	
	$(function() {
		docEditor = editormd("doc-editormd", {
			width   : "98%",
	        height  : 640,
	        toolbar : true,
	        codeFold : true,
	        syncScrolling : "single",
	        saveHTMLToTextarea : true,    // 保存 HTML 到 Textarea
	        path    : WEBROOT+"/plugin/markdown/lib/",
	        onload : function() {//加载完成事件
	        	docEditor.insertValue(content_code);//设置编辑器内容
			}

	    });
	});
</script>